package com.okaixz.client.controller;


import com.okaixz.client.model.dto.ShareInfoDto;
import com.okaixz.client.model.dto.UserDto;
import com.okaixz.client.service.IShareInfoService;
import com.okaixz.common.client.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cdz
 * @since 2024-11-10
 */
@RestController
@RequestMapping("/share")
public class ShareInfoController {

    @Autowired
    private IShareInfoService shareInfoService;

    @GetMapping("/list/{userId}")
    public Result<List<ShareInfoDto>> getListByUserId(@PathVariable(name = "userId",required = true) String userId){
        List<ShareInfoDto> list=shareInfoService.getListByUserId(userId);
        return Result.success(list);
    }
    @PostMapping("/submit")
    public Result<UserDto> submit(@RequestParam String userId, String code){
        UserDto user=shareInfoService.submit(userId,code);
        return Result.success(user);
    }

}
